package ru.ifmo.tanya.service.impl;

import ru.ifmo.tanya.core.users.User;
import ru.ifmo.tanya.keepers.OnlineUsersKeeper;
import ru.ifmo.tanya.service.AuthorizedHttpService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


public class LogOutServer extends AuthorizedHttpService {

    private final OnlineUsersKeeper onlineUsersKeeper = new OnlineUsersKeeper();

    @Override
    public void invokeWithUser(User user, HttpServletRequest request, HttpServletResponse response) throws IOException {
        onlineUsersKeeper.userLeft(user);
        response.sendRedirect("/");
    }
}
